layui.use(['Api', 'echarts', 'request'], function () {
	let echarts = layui.echarts;
    var Api = layui.Api,
        request = layui.request;

	var column2 = echarts.init(document.getElementById('column2'));

	var option = {
		tooltip: {
			trigger: 'item',
			formatter: '{b}: {c}%',
			textStyle: {
				"fontSize": 18
			}
		},
		series: [{
			type: 'gauge',
			anchor: {
				show: true,
				showAbove: true,
				size: 18,
				itemStyle: {
					color: '#FAC858'
				}
			},
			pointer: {
				icon: 'path://M2.9,0.7L2.9,0.7c1.4,0,2.6,1.2,2.6,2.6v115c0,1.4-1.2,2.6-2.6,2.6l0,0c-1.4,0-2.6-1.2-2.6-2.6V3.3C0.3,1.9,1.4,0.7,2.9,0.7z',
				width: 8,
				length: '80%',
				offsetCenter: [0, '8%']
			},

			progress: {
				show: true,
				overlap: true,
				roundCap: true
			},
			axisLine: {
				roundCap: true
			},
			data: [{
				value: 90,
				name: '移送率',
				title: {
					offsetCenter: ['25%', '80%']
				},
				detail: {
					offsetCenter: ['25%', '95%']
				},
				itemStyle: {
					color: '#5470C6'
				}
			},
			{
				value: 70,
				name: '查结率',
				title: {
					offsetCenter: ['-25%', '80%']
				},
				detail: {
					offsetCenter: ['-25%', '95%']
				},
				itemStyle: {
					color: '#91CC75'
				}
			},
			],
			title: {
				fontSize: 14
			},
			detail: {
				width: 40,
				height: 14,
				fontSize: 14,
				color: '#fff',
				backgroundColor: 'auto',
				borderRadius: 3,
				formatter: '{value}%'
			}
		}]
	};
	// column2.setOption(option);

	var success = function(res){
        // console.log(res.data.departmentNameList)
        // console.log(option.xAxis[0].data)
        // console.log(option.series[0].data)
		option.series[0].data[1].value = res.data.doneRatio // 查结率 
		option.series[0].data[1].name = '查结率'
		if(res.data.sendRatio == undefined) {
			option.series[0].data.shift()
			// option.series[0].data[0].value = res.data.feedbackRatio // 反馈率
			// option.series[0].data[0].name = '反馈率'
			option.series[0].data[0].title.offsetCenter[0] = '0%'
			option.series[0].data[0].detail.offsetCenter[0] = '0%'
		} else {
			option.series[0].data[0].value = res.data.sendRatio // 移送率
			option.series[0].data[0].name = '移送率'
		}
		
        column2.setOption(option);
    }
	var params = {
        isValid: layui.data('consoleSelect').item
    }
    request.get(Api.ratioPercent, params, success)

	window.optionReload =  function (url) {
        console.log('inner url2', url)
        // request.get(url, {}, success)
        // request.get(Api.countSendDepartment, {}, success)
    }
	
	window.onresize = function () {
		column2.resize();
	}
})

var column2Utils = {
    reloadOption: function (url){
        // console.log('reload column1 url', url)
        optionReload(url)
    },
}